﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Movies
{
    public class DTOMoviesDetails
    {

        private String[] retValue;
        public DTOMoviesDetails()
        {
            retValue = new String[17];
        }

        public DTOMoviesDetails(String title, String fileName)
        {
            retValue = new String[17];
            retValue[0] = title;
            retValue[16] = fileName;
        }
        public DTOMoviesDetails(String[] inputArray)
        {
            int index = 0;
            retValue = new String[17];
            foreach (String input in inputArray)
            {
                retValue[index] = input.Trim();
                index++;
            }
            correctVote();
            correctRuntime();
        }

        public DTOMoviesDetails(String[] inputArray, String fileLocation)
        {
            int index = 0;
            retValue = new String[17];
            foreach (String input in inputArray)
            {
                if (input != null)
                {
                    retValue[index] = input.Trim();
                }
                index++;
            }
            correctVote();
            correctRuntime();
            retValue[16] = fileLocation;
        }

        private void correctVote()
        {
            if (retValue[2] != null && !retValue[2].Trim().Equals("N/A") && !retValue[2].Trim().Equals(""))
            {
                for(int len=retValue[2].Length;len<=5;len++)
                {
                    retValue[2] = "0" + retValue[2];
                }
            }
        }

        private void correctRuntime()
        {
            if (retValue[3] != null && retValue[3].IndexOf(" hr") == -1 && retValue[3].IndexOf(" min")>-1)
            {
                retValue[3] = "0 hr " + retValue[3];
            }

        }

        public string Title {
            set { retValue[0] = value; }
            get { return retValue[0]; }
        }
        public string Rating{
            set { retValue[1] = value; }
            get { return retValue[1]; }
        }
        public string Votes{
            set { retValue[2] = value; correctVote(); }
            get { return retValue[2]; }
        }
        public string Runtime{
            set { retValue[3] = value; correctRuntime(); }
            get { return retValue[3]; }
        }
        public string Year{
            set { retValue[4] = value; }
            get { return retValue[4]; }
        }
        public string Rated{
            set { retValue[5] = value; }
            get { return retValue[5]; }
        }
        public string GenreList{
            set { retValue[6] = value; }
            get { return retValue[6]; }
        }
        public string Director{
            set { retValue[7] = value; }
            get { return retValue[7]; }
        }
        public string Writer{
            set { retValue[8] = value; }
            get { return retValue[8]; }
        }
        public string Actors{
            set { retValue[9] = value; }
            get { return retValue[9]; }
        }
        public string Released{
            set { retValue[10] = value.Trim(); }
            get { return retValue[10]; }
        }
        public string Plot{
            set { retValue[11] = value; }
            get { return retValue[11]; }
        }

        public string Studio
        {
            set { retValue[12] = value; }
            get { return retValue[12]; }
        }

        public string IMDBTitle
        {
            set { retValue[13] = value; }
            get { return retValue[13]; }
        }


        public string ImageFile
        {
            set { retValue[14] = value; }
            get { return retValue[14]; }
        }

        public string HTMLFile
        {
            set { retValue[15] = value; }
            get { return retValue[15]; }
        }

        public string FolderLocation
        {
            set { retValue[16] = value; }
            get { return retValue[16]; }
        }

        public String[] getDataArray()
        {
            return retValue;

        }
    }
}
